import Vue from 'vue'
import FastClick from 'fastclick'
import lazyLoad from 'vue-lazyload'
import App from './App.vue'
import router from './router/index.js'
import store from './store/index.js'
import toast from 'components/common/toast/index.js'
Vue.config.productionTip = false
Vue.prototype.$bus=new Vue()  //Vue实例可以充当事件总线
Vue.use(toast)
Vue.use(lazyLoad,{
  loading:require('./assets/logo.png')
})
FastClick.attach(document.body)
new Vue({
  render: h => h(App),
  router,
  store
}).$mount('#app')

window.addEventListener('beforeload', () => {
  console.log('before');
	let json = (new Function("return " + sessionStorage.user))();
	store.state.user=json

})

window.addEventListener('beforeunload', () => {
  sessionStorage.setItem('store', JSON.stringify(store.state))
})
// console.log(store.state);
